#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File    :   error_debug.py    
@Contact :   fengfeng.qiu@amh-group.com

@Modify Time      @Author    
------------      -------    
2022/2/14 10:38   qiufengfeng      
'''

import requests,json


def post_server(data):
    url = 'http://localhost:8000/phantom/tf-predict'
    header = {
        'Content-Type':"application/json"
    }
    post_data = {
        'dialogue':[data]
    }

    req = requests.post(url,data=json.dumps(post_data),headers=header)
    return req.json()



def process():
    filename = "error.txt"
    with open(filename,'r',encoding='utf-8') as fread:
        for line in fread:
            item = json.loads(line.strip())
            result = post_server(item)
            print(result)

if __name__ == '__main__':
    process()